package SpdgBI.PhErp;

import SpdgBI.Common.DBUtils;
import SpdgBI.Common.Udfs;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Map;

import static com.mchange.v2.c3p0.dbms.OracleUtils.createTemporaryCLOB;

public class Topic {
    public void PumpData(String PhName){
        String[] strDataType = {"NUMBER", "NVARCHAR2", "VARCHAR", "NCHAR", "CHAR", "CLOB", "NCLOB", "TIMESTAMP(6)"};
        List<String> lstDataType = new ArrayList<>(Arrays.asList(strDataType));
        List lstTblInfo = null;
        Connection connBI = null;
        Connection connPUBERP = null;
        PreparedStatement pstmtDp = null;
        PreparedStatement pstmtDataSrc = null;
        ResultSet rsDataSrc = null;
        String strSqlDataSrc = "SELECT a.TopicId,\n" +
                "       a.TopicCode,\n" +
                "       p.ProjectId,\n" +
                "       p.ProjectDisplayCode,\n" +
                "       a.TopicTitle,\n" +
                "       a.TopicSubTitle,\n" +
                "       a.ProductCategory ProductCategoryid,\n" +
                "       (SELECT DisplayName\n" +
                "          FROM ConstGroupSet cgs\n" +
                "         WHERE a.ProductCategory = cgs.StoredValue\n" +
                "           AND cgs.GroupId = 424) ProductCategory,\n" +
                "       a.ProductForm ProductFormid,\n" +
                "       (SELECT DisplayName\n" +
                "          FROM ConstGroupSet cgs\n" +
                "         WHERE a.ProductForm = cgs.StoredValue\n" +
                "           AND cgs.GroupId = 425) ProductForm,\n" +
                "       a.PublishMode PublishModeid,\n" +
                "       (SELECT DisplayName\n" +
                "          FROM ConstGroupSet cgs\n" +
                "         WHERE a.PublishMode = cgs.StoredValue\n" +
                "           AND cgs.GroupId = 246) PublishMode,\n" +
                "       SI.SeriesName,\n" +
                "       a.TopicState TopicStateid,\n" +
                "       (SELECT DisplayName\n" +
                "          FROM ConstGroupSet cgs\n" +
                "         WHERE a.TopicState = cgs.StoredValue\n" +
                "           AND cgs.GroupId = 0x4f) TopicState,\n" +
                "       a.IsbnCode ISBNCode,\n" +
                "       a.Submitter Submitterid,\n" +
                "       b.Name Submitter,\n" +
                "       CASE\n" +
                "         WHEN TopicDepartment <> 0 THEN\n" +
                "          TopicDepartment\n" +
                "         ELSE\n" +
                "          NULL\n" +
                "       END TopicDepartmentid,\n" +
                "       c.DepartmentName TopicDepartment,\n" +
                "       a.TopicPerson,\n" +
                "       a.TopicType TopicTypeid,\n" +
                "       (SELECT DisplayName\n" +
                "          FROM ConstGroupSet cgs\n" +
                "         WHERE a.TopicType = cgs.StoredValue\n" +
                "           AND cgs.GroupId = 12) TopicType,\n" +
                "       a.TopicProperty TopicPropertyid,\n" +
                "       (SELECT DisplayName\n" +
                "          FROM ConstGroupSet cgs\n" +
                "         WHERE a.TopicProperty = cgs.StoredValue\n" +
                "           AND cgs.GroupId = 225) TopicProperty,\n" +
                "       a.ComposingType ComposingTypeid,\n" +
                "       (SELECT DisplayName\n" +
                "          FROM ConstGroupSet cgs\n" +
                "         WHERE a.ComposingType = cgs.StoredValue\n" +
                "           AND cgs.GroupId = 0x1d) ComposingType,\n" +
                "       a.FormerlyLanguage FormerlyLanguageid,\n" +
                "       (SELECT DisplayName\n" +
                "          FROM ConstGroupSet cgs\n" +
                "         WHERE a.FormerlyLanguage = cgs.StoredValue\n" +
                "           AND cgs.GroupId = 187) FormerlyLanguage,\n" +
                "       a.LanguageType LanguageTypeid,\n" +
                "       (SELECT DisplayName\n" +
                "          FROM ConstGroupSet cgs\n" +
                "         WHERE a.LanguageType = cgs.StoredValue\n" +
                "           AND cgs.GroupId = 187) LanguageType,\n" +
                "       a.TopicOwner TopicOwnerid,\n" +
                "       (SELECT DisplayName\n" +
                "          FROM ConstGroupSet cgs\n" +
                "         WHERE a.TopicOwner = cgs.StoredValue\n" +
                "           AND cgs.GroupId = 181) TopicOwner,\n" +
                "       a.bookformat bookformatid,\n" +
                "       (SELECT SpecFormatName\n" +
                "          FROM SpecFormat\n" +
                "         WHERE SpecFormat.SpecFormatid = a.bookformat) bookformat,\n" +
                "       a.DimensionFormat DimensionFormatid,\n" +
                "       (SELECT DisplayName\n" +
                "          FROM DimensionFormat\n" +
                "         WHERE DimensionFormat.DimensionFormatId = a.DimensionFormat) DimensionFormat,\n" +
                "       a.BindingFormat BindingFormatid,\n" +
                "       (SELECT DisplayName\n" +
                "          FROM ConstGroupSet cgs\n" +
                "         WHERE a.BindingFormat = cgs.StoredValue\n" +
                "           AND cgs.GroupId = 8) BindingFormat,\n" +
                "       a.BindingShape BindingShapeid,\n" +
                "       (SELECT DisplayName\n" +
                "          FROM ConstGroupSet cgs\n" +
                "         WHERE a.BindingShape = cgs.StoredValue\n" +
                "           AND cgs.GroupId = 450) BindingShape,\n" +
                "       a.RemunerationStyle RemunerationStyleid,\n" +
                "       (SELECT DisplayName\n" +
                "          FROM ConstGroupSet cgs\n" +
                "         WHERE a.RemunerationStyle = cgs.StoredValue\n" +
                "           AND cgs.GroupId = 176) RemunerationStyle,\n" +
                "       a.BookType BookTypeid,\n" +
                "       d.BookTypeName BookType,\n" +
                "       a.IsImportant, --是否重大\n" +
                "       a.ImportantRead ImportantReadid,\n" +
                "       (SELECT DisplayName\n" +
                "          FROM ConstGroupSet cgs\n" +
                "         WHERE a.ImportantRead = cgs.StoredValue\n" +
                "           AND cgs.GroupId = 218) ImportantRead,\n" +
                "       a.ImportantType,\n" +
                "       a.EditionModel EditionModelid,\n" +
                "       (SELECT DisplayName\n" +
                "          FROM ConstGroupSet cgs\n" +
                "         WHERE a.EditionModel = cgs.StoredValue\n" +
                "           AND cgs.GroupId = 252) EditionModel,\n" +
                "       a.EditionType EditionTypeid,\n" +
                "       (SELECT DisplayName\n" +
                "          FROM ConstGroupSet cgs\n" +
                "         WHERE a.EditionType = cgs.StoredValue\n" +
                "           AND cgs.GroupId = 253) EditionType,\n" +
                "       a.BespeakCodeId,\n" +
                "       a.CoverLayoutDesign,\n" +
                "       a.IsTranslate, --是否引进\n" +
                "       a.TranslateType TranslateTypeid,\n" +
                "       (SELECT DisplayName\n" +
                "          FROM ConstGroupSet cgs\n" +
                "         WHERE a.TranslateType = cgs.StoredValue\n" +
                "           AND cgs.GroupId = 255) TranslateType,\n" +
                "       a.MakingType MakingTypeid,\n" +
                "       (SELECT DisplayName\n" +
                "          FROM ConstGroupSet cgs\n" +
                "         WHERE a.MakingType = cgs.StoredValue\n" +
                "           AND cgs.GroupId = 256) MakingType,\n" +
                "       a.TranslateCountry TranslateCountryid,\n" +
                "       (SELECT DisplayName\n" +
                "          FROM ConstGroupSet cgs\n" +
                "         WHERE a.TranslateCountry = cgs.StoredValue\n" +
                "           AND cgs.GroupId = 257) TranslateCountry,\n" +
                "       a.TextbookType TextbookTypeid,\n" +
                "       tbt.DisplayName TextbookType,\n" +
                "       a.CLawType CLawTypeid,\n" +
                "       ct.clawtypename clawtype,\n" +
                "       a.BookProperty BookPropertyid,\n" +
                "       (SELECT DisplayName\n" +
                "          FROM ConstGroupSet cgs\n" +
                "         WHERE a.BookProperty = cgs.StoredValue\n" +
                "           AND cgs.GroupId = 184) BookProperty,\n" +
                "       a.ReaderRange ReaderRangeid,\n" +
                "       (SELECT DisplayName\n" +
                "          FROM ConstGroupSet cgs\n" +
                "         WHERE a.ReaderRange = cgs.StoredValue\n" +
                "           AND cgs.GroupId = 259) ReaderRange,\n" +
                "       a.SubmitrackAdvice SubmitrackAdviceid,\n" +
                "       (SELECT DisplayName\n" +
                "          FROM ConstGroupSet cgs\n" +
                "         WHERE a.SubmitrackAdvice = cgs.StoredValue\n" +
                "           AND cgs.GroupId = 183) SubmitrackAdvice,\n" +
                "       (SELECT GenreWordName\n" +
                "          FROM GenreWord\n" +
                "         WHERE a.GenreWordOne = GenreWord.GenreWordId) GenreWordOne,\n" +
                "       (SELECT GenreWordName\n" +
                "          FROM GenreWord\n" +
                "         WHERE a.GenreWordTwo = GenreWord.GenreWordId) GenreWordTwo,\n" +
                "       A.TYear,\n" +
                "       A.TMonth,\n" +
                "       a.SalesType SalesTypeid,\n" +
                "       (SELECT DisplayName\n" +
                "          FROM ConstGroupSet cgs\n" +
                "         WHERE a.SalesType = cgs.StoredValue\n" +
                "           AND cgs.GroupId = 160) SalesType,\n" +
                "       a.BundleAnnul, --是否包销\n" +
                "       a.IsEmend, --是否修订\n" +
                "       a.ReleaseVersion,\n" +
                "       a.PrintingVersion,\n" +
                "       a.ScriptSource ScriptSourceid,\n" +
                "       ss.ScriptSourceName ScriptSource,\n" +
                "       a.EmergencyDegree EmergencyDegreeid,\n" +
                "       (SELECT DisplayName\n" +
                "          FROM ConstGroupSet cgs\n" +
                "         WHERE a.EmergencyDegree = cgs.StoredValue\n" +
                "           AND cgs.GroupId = 285) EmergencyDegree,\n" +
                "       a.SubmitTime,\n" +
                "       fm.ApproveTime,\n" +
                "       fm.AKTime StartDate,\n" +
                "       fm.Name AccountKeeper,\n" +
                "       p.ScriptSubmitDate ScriptSubmitDate,\n" +
                "       a.AuthorName,\n" +
                "       a.RemunerationReplain,\n" +
                "       a.TopicWordCount TopicWordCount_3,\n" +
                "       a.BaseSalary,\n" +
                "       a.PrintAmountPayment AS PrintAmountPayment,\n" +
                "       CAST(a.EditionAmountPayment AS VARCHAR) + ' %' AS EditionAmountPayment,\n" +
                "       a.PlanPrice xPlanPrice,\n" +
                "       a.FirstPrintAmount,\n" +
                "       a.IntendingSalesVolume,\n" +
                "       a.PictureCount,\n" +
                "       a.PrintSheetAmount,\n" +
                "       a.CarrierShape AS CarrierShape,\n" +
                "       a.CDNum AS CDNum,\n" +
                "       a.ActTime AS ActTime,\n" +
                "       a.IntendingGain,\n" +
                "       a.IsHired,\n" +
                "       a.IsGroupSupervise,\n" +
                "       a.PlannedScriptSubmitDate PlanSentScriptDate,\n" +
                "       a.PlannedReleaseDate PlannedReleaseDate,\n" +
                "       a.IsPublic,\n" +
                "       a.IsBookNumber,\n" +
                "       a.IsPressNumber,\n" +
                "       a.CooperativePublishId,\n" +
                "       a.re1,\n" +
                "       a.re2,\n" +
                "       a.re3,\n" +
                "       a.re4,\n" +
                "       a.re5,\n" +
                "       a.re6,\n" +
                "       CASE\n" +
                "         WHEN a.RE1 IS NOT NULL THEN\n" +
                "          (SELECT Name FROM Employee WHERE a.RE1 = Employee.EmployeeId)\n" +
                "       END RE1DisplayName,\n" +
                "       CASE\n" +
                "         WHEN a.RE2 IS NOT NULL THEN\n" +
                "          (SELECT Name FROM Employee WHERE a.RE2 = Employee.EmployeeId)\n" +
                "       END RE2DisplayName,\n" +
                "       CASE\n" +
                "         WHEN a.RE3 IS NOT NULL THEN\n" +
                "          (SELECT Name FROM Employee WHERE a.RE3 = Employee.EmployeeId)\n" +
                "       END RE3DisplayName,\n" +
                "       CASE\n" +
                "         WHEN a.RE4 IS NOT NULL THEN\n" +
                "          (SELECT Name FROM Employee WHERE a.RE4 = Employee.EmployeeId)\n" +
                "       END RE4DisplayName,\n" +
                "       CASE\n" +
                "         WHEN a.RE5 IS NOT NULL THEN\n" +
                "          (SELECT Name FROM Employee WHERE a.RE5 = Employee.EmployeeId)\n" +
                "       END RE5DisplayName,\n" +
                "       CASE\n" +
                "         WHEN a.RE6 IS NOT NULL THEN\n" +
                "          (SELECT Name FROM Employee WHERE a.RE6 = Employee.EmployeeId)\n" +
                "       END RE6DisplayName,\n" +
                "       CASE\n" +
                "         WHEN a.RE1Rate IS NOT NULL THEN\n" +
                "          CAST(a.RE1Rate AS VARCHAR(20)) + '%'\n" +
                "       END RE1Rate,\n" +
                "       CASE\n" +
                "         WHEN a.RE2Rate IS NOT NULL THEN\n" +
                "          CAST(a.RE2Rate AS VARCHAR(20)) + '%'\n" +
                "       END RE2Rate,\n" +
                "       CASE\n" +
                "         WHEN a.RE3Rate IS NOT NULL THEN\n" +
                "          CAST(a.RE3Rate AS VARCHAR(20)) + '%'\n" +
                "       END RE3Rate,\n" +
                "       CASE\n" +
                "         WHEN a.RE4Rate IS NOT NULL THEN\n" +
                "          CAST(a.RE4Rate AS VARCHAR(20)) + '%'\n" +
                "       END RE4Rate,\n" +
                "       CASE\n" +
                "         WHEN a.RE5Rate IS NOT NULL THEN\n" +
                "          CAST(a.RE5Rate AS VARCHAR(20)) + '%'\n" +
                "       END RE5Rate,\n" +
                "       CASE\n" +
                "         WHEN a.RE6Rate IS NOT NULL THEN\n" +
                "          CAST(a.RE6Rate AS VARCHAR(20)) + '%'\n" +
                "       END RE6Rate,\n" +
                "       TC1.Content IntroContent,\n" +
                "       TC1.SubmitTime IntroTime,\n" +
                "       TC2.Content SyllabusContent,\n" +
                "       TC2.SubmitTime SyllabusTime,\n" +
                "       TC3.Content DesignContent,\n" +
                "       TC3.SubmitTime DesignTime,\n" +
                "       TC4.Content MarketContent,\n" +
                "       TC4.SubmitTime MarketTime,\n" +
                "       TC5.Content CostBudgetContent,\n" +
                "       TC5.SubmitTime CostBudgetTime,\n" +
                "       TC6.Content AuthorIntroduceContent,\n" +
                "       TC6.SubmitTime AuthorIntroduceTime,\n" +
                "       TC8.Content topicideaContent,\n" +
                "       TC8.SubmitTime topicideaTime,\n" +
                "       TC9.Content ReaderObjectContent,\n" +
                "       TC9.SubmitTime ReaderObjectTime,\n" +
                "       TC10.Content TraithContent,\n" +
                "       TC10.SubmitTime TraithTime,\n" +
                "       TC11.Content ConGenerContent,\n" +
                "       TC11.SubmitTime ConGenerTime,\n" +
                "       TC12.Content MartsellContent,\n" +
                "       TC12.SubmitTime MartsellTime,\n" +
                "       TC13.Content DepProveContent,\n" +
                "       TC13.SubmitTime DepProveTime,\n" +
                "       TC13.Name DepProvePerson,\n" +
                "       TC14.Content SelectTopicProveContent,\n" +
                "       TC14.SubmitTime SelectTopicProveTime,\n" +
                "       TC14.Name SelectTopicProvePerson,\n" +
                "       TC15.Content SheweiProveContent,\n" +
                "       TC15.SubmitTime SheweiProveTime,\n" +
                "       TC15.Name SheweiProvePerson,\n" +
                "       TC16.Content MarketProveContent,\n" +
                "       TC16.SubmitTime MarketProveTime,\n" +
                "       TC16.Name MarketProvePerson,\n" +
                "       TC17.Content SendAuditContent,\n" +
                "       TC17.SubmitTime SendAuditTime,\n" +
                "       TC17.Name SendAuditPerson,\n" +
                "       a.PublishingFundId,\n" +
                "       a.AwardsDeclarationId,\n" +
                "       a.ImportantTopicId,\n" +
                "       a.MarketingPersonnel MarketingPersonnel_NAMES,\n" +
                "       a.ReportType\n" +
                "  FROM Topic a\n" +
                "  LEFT JOIN Employee b\n" +
                "    ON a.Submitter = b.EmployeeId\n" +
                "  LEFT JOIN Department c\n" +
                "    ON a.TopicDepartment = c.DepartmentId\n" +
                "  LEFT JOIN BookType d\n" +
                "    ON a.BookType = d.BookTypeId\n" +
                "   AND d.Isinuse = 1\n" +
                "  LEFT JOIN Project p\n" +
                "    ON p.ProjectId = a.TopicId\n" +
                "  LEFT JOIN (SELECT FORMID,\n" +
                "                    ACCOUNTKEEPER,\n" +
                "                    AKTIME,\n" +
                "                    ApproveTime,\n" +
                "                    Employee.Name\n" +
                "               FROM FORM f\n" +
                "               LEFT JOIN Employee\n" +
                "                 ON f.ACCOUNTKEEPER = Employee.EmployeeId) FM\n" +
                "    ON fM.FormId = a.TopicId\n" +
                "  LEFT JOIN Series SI\n" +
                "    ON a.SeriesInfo = SI.SeriesId\n" +
                "  LEFT JOIN CLawType ct\n" +
                "    ON a.CLawType = ct.ClawTypeId\n" +
                "  LEFT JOIN ScriptSource ss\n" +
                "    ON a.ScriptSource = ss.ScriptSourceId\n" +
                "  LEFT JOIN TextbookType tbt\n" +
                "    ON A.TextbookType = tbt.TextBookTypeId\n" +
                "\n" +
                "  LEFT JOIN (SELECT TC.ProjectId, TC.SubmitTime, TC.Content\n" +
                "               FROM TopicComment tc\n" +
                "               LEFT JOIN Topic TP\n" +
                "                 ON TC.ProjectId = TP.TopicId\n" +
                "              WHERE tc.CommentType = (CASE\n" +
                "                      WHEN tp.TopicType = 1 THEN\n" +
                "                       101\n" +
                "                      WHEN TP.TopicType = 2 THEN\n" +
                "                       108\n" +
                "                      ELSE\n" +
                "                       NULL\n" +
                "                    END)\n" +
                "                AND tc.ProjectId = TP.TopicId) TC1 --ContentIntroduction\n" +
                "    ON TC1.ProjectId = A.TopicId\n" +
                "  LEFT JOIN (SELECT ProjectId, SubmitTime, Content\n" +
                "               FROM TopicComment\n" +
                "              WHERE CommentType = 102) TC2 --Syllabus\n" +
                "    ON TC2.ProjectId = A.TopicId\n" +
                "\n" +
                "  LEFT JOIN (SELECT ProjectId, SubmitTime, Content\n" +
                "               FROM TopicComment\n" +
                "              WHERE CommentType = 103) TC3 --Architecture\n" +
                "    ON TC3.ProjectId = A.TopicId\n" +
                "\n" +
                "  LEFT JOIN (SELECT ProjectId, SubmitTime, Content\n" +
                "               FROM TopicComment\n" +
                "              WHERE CommentType = 104) TC4 --MarketAnalyst\n" +
                "    ON TC4.ProjectId = A.TopicId\n" +
                "  LEFT JOIN (SELECT ProjectId, SubmitTime, Content\n" +
                "               FROM TopicComment\n" +
                "              WHERE CommentType = 105) TC5 --CostBudget\n" +
                "    ON TC5.ProjectId = A.TopicId\n" +
                "  LEFT JOIN (SELECT ProjectId, SubmitTime, Content\n" +
                "               FROM TopicComment\n" +
                "              WHERE CommentType = 106) TC6 --AuthorIntroduce\n" +
                "    ON TC6.ProjectId = A.TopicId\n" +
                "\n" +
                "  LEFT JOIN (SELECT ProjectId, SubmitTime, Content\n" +
                "               FROM TopicComment\n" +
                "              WHERE CommentType = 108) TC8 --topicidea\n" +
                "    ON TC8.ProjectId = A.TopicId\n" +
                "  LEFT JOIN (SELECT ProjectId, SubmitTime, Content\n" +
                "               FROM TopicComment\n" +
                "              WHERE CommentType = 109) TC9 --ReaderObject\n" +
                "    ON TC9.ProjectId = A.TopicId\n" +
                "\n" +
                "  LEFT JOIN (SELECT ProjectId, SubmitTime, Content\n" +
                "               FROM TopicComment\n" +
                "              WHERE CommentType = 110) TC10 --Traith\n" +
                "    ON TC10.ProjectId = A.TopicId\n" +
                "  LEFT JOIN (SELECT ProjectId, SubmitTime, Content\n" +
                "               FROM TopicComment\n" +
                "              WHERE CommentType = 111) TC11 --ConGener\n" +
                "    ON TC11.ProjectId = A.TopicId\n" +
                "  LEFT JOIN (SELECT ProjectId, SubmitTime, Content\n" +
                "               FROM TopicComment\n" +
                "              WHERE CommentType = 112) TC12 --Martsell\n" +
                "    ON TC12.ProjectId = A.TopicId\n" +
                "  LEFT JOIN (SELECT ProjectId, SubmitTime, Content, Employee.Name\n" +
                "               FROM TopicComment\n" +
                "               LEFT JOIN Employee\n" +
                "                 ON TopicComment.Submitter = Employee.EmployeeId\n" +
                "              WHERE CommentType = 7) TC13 --DepProve\n" +
                "    ON TC13.ProjectId = A.TopicId\n" +
                "  LEFT JOIN (SELECT ProjectId, SubmitTime, Content, Employee.Name\n" +
                "               FROM TopicComment\n" +
                "               LEFT JOIN Employee\n" +
                "                 ON TopicComment.Submitter = Employee.EmployeeId\n" +
                "              WHERE CommentType = 8) TC14 --SelectTopicProve\n" +
                "    ON TC14.ProjectId = A.TopicId\n" +
                "  LEFT JOIN (SELECT ProjectId, SubmitTime, Content, Employee.Name\n" +
                "               FROM TopicComment\n" +
                "               LEFT JOIN Employee\n" +
                "                 ON TopicComment.Submitter = Employee.EmployeeId\n" +
                "              WHERE CommentType = 9) TC15 --SheweiProve\n" +
                "    ON TC15.ProjectId = A.TopicId\n" +
                "  LEFT JOIN (SELECT ProjectId, SubmitTime, Content, Employee.Name\n" +
                "               FROM TopicComment\n" +
                "               LEFT JOIN Employee\n" +
                "                 ON TopicComment.Submitter = Employee.EmployeeId\n" +
                "              WHERE CommentType = 23) TC16 --MarketProve\n" +
                "    ON TC16.ProjectId = A.TopicId\n" +
                "  LEFT JOIN (SELECT ProjectId, SubmitTime, Content, Employee.Name\n" +
                "               FROM TopicComment\n" +
                "               LEFT JOIN Employee\n" +
                "                 ON TopicComment.Submitter = Employee.EmployeeId\n" +
                "              WHERE CommentType = 25) TC17 --SendAudit\n" +
                "    ON TC17.ProjectId = A.TopicId\n" +
                "\n" +
                " WHERE 1 = 1\n";
        String strDel = "DELETE FROM BASE_PUB_TOPIC WHERE UNITCODE = ?";
        Long endTime;
        Long StartTime;
        try {
            StartTime = System.currentTimeMillis();
            connPUBERP = DBUtils.getConnection(PhName);
            pstmtDataSrc = connPUBERP.prepareStatement(strSqlDataSrc);
            rsDataSrc = pstmtDataSrc.executeQuery();

            connBI = DBUtils.getConnection("SPDGBI");
            connBI.setAutoCommit(false);
            lstTblInfo = Udfs.GetTableInfo("BASE_PUB_TOPIC");

            pstmtDp = connBI.prepareStatement(strDel);
            pstmtDp.setString(1,PhName);
            pstmtDp.execute();

            pstmtDp = connBI.prepareStatement(((Map)lstTblInfo.get(lstTblInfo.size() - 1)).get("sqlins").toString());

            oracle.sql.CLOB clob = null;
            while (rsDataSrc.next()) {
                pstmtDp.setString(1, PhName);
                for (int i = 1; i < lstTblInfo.size() - 1; i++) {
                    switch (lstDataType.indexOf(((Map)lstTblInfo.get(i)).get("DATA_TYPE").toString())) {
                        case 0:
                            pstmtDp.setFloat(i + 1, rsDataSrc.getFloat(((Map)lstTblInfo.get(i)).get("COLUMN_NAME").toString()));
                            break;
                        case 1:
                        case 2:
                        case 3:
                        case 4:
                        case 5:
                        case 6:
                            pstmtDp.setString(i + 1, rsDataSrc.getString(((Map)lstTblInfo.get(i)).get("COLUMN_NAME").toString()));
                            break;
                        case 7:
                            pstmtDp.setTimestamp(i + 1, rsDataSrc.getTimestamp(((Map) lstTblInfo.get(i)).get("COLUMN_NAME").toString()));
                            break;
                        default:
                            pstmtDp.setObject(i + 1, rsDataSrc.getString(((Map)lstTblInfo.get(i)).get("COLUMN_NAME").toString()));
                            break;
                    }
                }
                pstmtDp.addBatch();
            }
            pstmtDp.executeBatch();
            pstmtDp.clearParameters();
            pstmtDp.clearBatch();
            connBI.commit();
            endTime = System.currentTimeMillis();
            System.out.println("抽取数据完成，出版单位编码为" + PhName + "的选题数据抽取完成，用时：" + (endTime - StartTime));

        } catch (Exception ex) {
            ex.printStackTrace();
        }finally {
            lstTblInfo = null;
            DBUtils.close(connBI);
        }

    }

    public void PumpDataAll(){
        String[] PhList = {"010200", "0104", "010500", "010600", "010700", "0109","011000"};

        for (int i = 0; i < PhList.length; i++) {
            try {
                PumpData(PhList[i]);
            }catch (Exception ex){
                ex.printStackTrace();
                System.out.println("抽取数据时出错，抽取出版单位编码为" + PhList[i] + "的选题数据没有成功");
            }
        }

    }
}
